/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * LaporanPenjualan.java
 *
 * Created on Aug 18, 2010, 8:44:45 AM
 */
package com.ivanbiz.gui;

import com.ivanbiz.dao.NotaDAO;
import com.ivanbiz.helper.CenterRenderer;
import com.ivanbiz.helper.EngineReport;
import com.ivanbiz.helper.RightRenderer;
import com.ivanbiz.impl.NotaDAOImpl;
import com.ivanbiz.model.ItemNota;
import com.ivanbiz.model.Nota;
import com.ivanbiz.report.Report;
import java.awt.print.PrinterException;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author Aprisma
 */
public class LaporanPenjualan extends javax.swing.JInternalFrame {

    NotaDAO notaDAO = new NotaDAOImpl();
    List<ItemNota> listItemNota = new ArrayList<ItemNota>();
    NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMMM yyyy");

    /** Creates new form LaporanPenjualan */
    public LaporanPenjualan() {
        initComponents();
        updateData();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dialogLaporanPenjualan = new javax.swing.JDialog();
        jScrollPane2 = new javax.swing.JScrollPane();
        textAreaLaporanPenjualan = new javax.swing.JTextArea();
        buttonCetak = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        dateAwal = new org.jdesktop.swingx.JXDatePicker();
        dateAkhir = new org.jdesktop.swingx.JXDatePicker();
        textNoNota = new javax.swing.JTextField();
        buttonProsess = new javax.swing.JButton();
        labelAwal = new javax.swing.JLabel();
        labelAkhir = new javax.swing.JLabel();
        labelNota = new javax.swing.JLabel();
        buttonPrint = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableItemNota = new javax.swing.JTable();
        labelPT = new javax.swing.JLabel();
        labelAlamat = new javax.swing.JLabel();
        labelTelp = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        textTotal = new javax.swing.JTextField();

        dialogLaporanPenjualan.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        dialogLaporanPenjualan.setModal(true);

        textAreaLaporanPenjualan.setColumns(20);
        textAreaLaporanPenjualan.setRows(5);
        jScrollPane2.setViewportView(textAreaLaporanPenjualan);

        buttonCetak.setFont(new java.awt.Font("Tahoma", 1, 11));
        buttonCetak.setText("Cetak");
        buttonCetak.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCetakActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dialogLaporanPenjualanLayout = new javax.swing.GroupLayout(dialogLaporanPenjualan.getContentPane());
        dialogLaporanPenjualan.getContentPane().setLayout(dialogLaporanPenjualanLayout);
        dialogLaporanPenjualanLayout.setHorizontalGroup(
            dialogLaporanPenjualanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dialogLaporanPenjualanLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonCetak))
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 544, Short.MAX_VALUE)
        );
        dialogLaporanPenjualanLayout.setVerticalGroup(
            dialogLaporanPenjualanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dialogLaporanPenjualanLayout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonCetak))
        );

        setBorder(new org.jdesktop.swingx.border.DropShadowBorder());
        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setTitle("Laporan Penjualan");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Cari Berdasar Tanggal"));

        dateAwal.setFont(new java.awt.Font("Tahoma", 1, 11));

        dateAkhir.setFont(new java.awt.Font("Tahoma", 1, 11));

        textNoNota.setFont(new java.awt.Font("Tahoma", 1, 11));
        textNoNota.setText("jTextField1");

        buttonProsess.setFont(new java.awt.Font("Tahoma", 1, 11));
        buttonProsess.setText("Cari");
        buttonProsess.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonProsessActionPerformed(evt);
            }
        });

        labelAwal.setFont(new java.awt.Font("Tahoma", 1, 11));
        labelAwal.setText("Dari Tanggal");

        labelAkhir.setFont(new java.awt.Font("Tahoma", 1, 11));
        labelAkhir.setText("Ke Tanggal");

        labelNota.setFont(new java.awt.Font("Tahoma", 1, 11));
        labelNota.setText("No Nota");

        buttonPrint.setFont(new java.awt.Font("Tahoma", 1, 11));
        buttonPrint.setText("Print");
        buttonPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonPrintActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelAwal)
                    .addComponent(labelAkhir)
                    .addComponent(labelNota))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(dateAkhir, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
                    .addComponent(dateAwal, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
                    .addComponent(textNoNota, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(buttonProsess)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 80, Short.MAX_VALUE)
                        .addComponent(buttonPrint)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelAwal)
                    .addComponent(dateAwal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(dateAkhir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textNoNota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(labelAkhir)
                        .addGap(18, 18, 18)
                        .addComponent(labelNota)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buttonPrint)
                    .addComponent(buttonProsess))
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Table Laporan Penjualan"));

        tableItemNota.setAutoCreateRowSorter(true);
        tableItemNota.setFont(new java.awt.Font("Tahoma", 1, 11));
        tableItemNota.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableItemNota.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableItemNotaMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tableItemNota);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 734, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
                .addContainerGap())
        );

        labelPT.setFont(new java.awt.Font("Tahoma", 1, 36));
        labelPT.setText("PT BERGUNA JAYA");

        labelAlamat.setFont(new java.awt.Font("Tahoma", 1, 14));
        labelAlamat.setText("Jln. Jembatan Selatan no 470 Panglima Polim Jakarta Selatan ");

        labelTelp.setFont(new java.awt.Font("Tahoma", 1, 14));
        labelTelp.setText("Telp : 08174820800");

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Total"));

        textTotal.setEditable(false);
        textTotal.setFont(new java.awt.Font("Tahoma", 1, 18));
        textTotal.setText("jTextField2");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(textTotal, javax.swing.GroupLayout.DEFAULT_SIZE, 734, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(textTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(12, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelPT)
                            .addComponent(labelAlamat, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)
                            .addComponent(labelTelp))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(labelPT)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelAlamat)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(labelTelp))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-800)/2, (screenSize.height-550)/2, 800, 550);
    }// </editor-fold>//GEN-END:initComponents

    private void buttonProsessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonProsessActionPerformed
        try {
            if (textNoNota.getText().equals("")) {
                listItemNota = notaDAO.getData(ItemNota.class, dateAwal.getDate(), dateAkhir.getDate());
                updateData();
            } else {
                Nota nota = (Nota) notaDAO.getDataByEqual(Nota.class, "kode", textNoNota.getText().toUpperCase());
                listItemNota = nota.getItemNota();
                updateData();
            }
        } catch (Exception ex) {
            Logger.getLogger(LaporanPenjualan.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_buttonProsessActionPerformed

    private void buttonPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPrintActionPerformed
        try {
            if (textNoNota.getText().equals("")) {
                SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                Date start = dateAwal.getDate();
                start.setHours(0);
                start.setMinutes(0);
                start.setSeconds(0);
                Date end = dateAkhir.getDate();
                end.setHours(0);
                end.setMinutes(0);
                end.setSeconds(0);
                EngineReport engineReport = new EngineReport();
                if (listItemNota.size() == 0) {
                    listItemNota = notaDAO.getData(ItemNota.class, start, end);
//                    textAreaLaporanPenjualan.setText(engineReport.printReportPenjualanTest(listItemNota, start, end).toString());
//                    dialogLaporanPenjualan.setSize(925, 700);
//                    dialogLaporanPenjualan.setVisible(true);
                    engineReport.printReportPenjualan(listItemNota, start, end);                    
//                    JOptionPane.showMessageDialog(null, "Data Sudah Tercetak di Folder C:\\BergunaJaya\\PDF\\");
//                    listItemNota.clear();
//                    updateTableItemNota();
                } else {
//                    textAreaLaporanPenjualan.setText(engineReport.printReportPenjualanTest(listItemNota, start, end).toString());
//                    dialogLaporanPenjualan.setSize(925, 700);
//                    dialogLaporanPenjualan.setVisible(true);
                    engineReport.printReportPenjualan(listItemNota, start, end);
//                    Runtime.getRuntime().exec("cmd /c start C:\\BergunaJaya\\Laporan.txt");
//                    JOptionPane.showMessageDialog(null, "Data Sudah Tercetak di Folder C:\\BergunaJaya\\PDF\\");
//                    listItemNota.clear();
//                    updateTableItemNota();
                }
                Report report = new Report();
                report.setTanggalAwal(simpleDateFormat1.format(start));
                report.setTanggalAkhir(simpleDateFormat1.format(end));
                report.reportPenjualanByTanggal();
            } else {
                Nota nota = (Nota) notaDAO.getDataByEqual(Nota.class, "kode", textNoNota.getText().toUpperCase());
                if (nota.getStatusPembayaran().equals("Kredit")) {
                    Report report = new Report();
                    report.setNoNota(textNoNota.getText().toUpperCase());
                    report.reportPenjualanByNotaKredit();
                }
                if (nota.getStatusPembayaran().equals("Tunai")) {
                    Report report = new Report();
                    report.setNoNota(textNoNota.getText().toUpperCase());
                    report.reportPenjualanByNotaTunai();
                }
            }
        } catch (Exception ex) {
            Logger.getLogger(LaporanPenjualan.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_buttonPrintActionPerformed

    private void tableItemNotaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableItemNotaMouseClicked
        ItemNota itemNota = listItemNota.get(tableItemNota.getSelectedRow());
        textNoNota.setText(itemNota.getNota().getKode());
    }//GEN-LAST:event_tableItemNotaMouseClicked

private void buttonCetakActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCetakActionPerformed
    try {
        textAreaLaporanPenjualan.print();//GEN-LAST:event_buttonCetakActionPerformed
        } catch (PrinterException ex) {
            Logger.getLogger(LaporanPenjualan.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonCetak;
    private javax.swing.JButton buttonPrint;
    private javax.swing.JButton buttonProsess;
    private org.jdesktop.swingx.JXDatePicker dateAkhir;
    private org.jdesktop.swingx.JXDatePicker dateAwal;
    private javax.swing.JDialog dialogLaporanPenjualan;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel labelAkhir;
    private javax.swing.JLabel labelAlamat;
    private javax.swing.JLabel labelAwal;
    private javax.swing.JLabel labelNota;
    private javax.swing.JLabel labelPT;
    private javax.swing.JLabel labelTelp;
    private javax.swing.JTable tableItemNota;
    private javax.swing.JTextArea textAreaLaporanPenjualan;
    private javax.swing.JTextField textNoNota;
    private javax.swing.JTextField textTotal;
    // End of variables declaration//GEN-END:variables

    private void updateData() {
        textNoNota.setText("");
        textTotal.setText("");
        updateTableItemNota();
        updateTotal();
    }

    private void updateTableItemNota() {
        String[] judul = {"No", "Tanggal Transaksi", "Nota Penjualan", "Nama Barang", "Satuan", "Jumlah", "Harga", "Sub Total"};
        Object[][] isi = new Object[listItemNota.size()][8];
        int x = 0;
        int no = 0;
        String kode = "";
        for (ItemNota itemNota : listItemNota) {
            if (!itemNota.getNota().getKode().equals(kode)) {
                kode = itemNota.getNota().getKode();
                isi[x][0] = no += 1;
                isi[x][1] = simpleDateFormat.format(itemNota.getCreateDate());
                isi[x][2] = itemNota.getNota().getKode();
            } else {
                isi[x][1] = "";
                isi[x][2] = "";
            }
            isi[x][3] = itemNota.getBarang().getNama();
            isi[x][4] = itemNota.getBarang().getSatuan().getNama();
            isi[x][5] = itemNota.getJumlah();
            isi[x][6] = "Rp " + numberFormat.format(itemNota.getHargaJual()) + ",00";
            isi[x][7] = "Rp " + numberFormat.format(itemNota.getHargaJual() * itemNota.getJumlah()) + ",00";
            x++;
        }
        tableItemNota.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return false;
            }
        });
        TableColumn column0 = tableItemNota.getColumnModel().getColumn(0);
        column0.setPreferredWidth(70);
        column0.setMaxWidth(70);
        column0.setCellRenderer(new CenterRenderer());
        TableColumn column1 = tableItemNota.getColumnModel().getColumn(1);
        column1.setPreferredWidth(120);
        column1.setMaxWidth(120);
        column1.setCellRenderer(new CenterRenderer());
        TableColumn column2 = tableItemNota.getColumnModel().getColumn(2);
        column2.setPreferredWidth(100);
        column2.setMaxWidth(100);
        column2.setCellRenderer(new CenterRenderer());
        TableColumn column4 = tableItemNota.getColumnModel().getColumn(4);
        column4.setPreferredWidth(100);
        column4.setMaxWidth(100);
        column4.setCellRenderer(new CenterRenderer());
        TableColumn column5 = tableItemNota.getColumnModel().getColumn(5);
        column5.setPreferredWidth(75);
        column5.setMaxWidth(75);
        column5.setCellRenderer(new CenterRenderer());
        TableColumn column6 = tableItemNota.getColumnModel().getColumn(6);
        column6.setPreferredWidth(140);
        column6.setMaxWidth(140);
        column6.setCellRenderer(new RightRenderer());
        TableColumn column7 = tableItemNota.getColumnModel().getColumn(7);
        column7.setPreferredWidth(140);
        column7.setMaxWidth(140);
        column7.setCellRenderer(new RightRenderer());
    }

    private void updateTotal() {
        double total = 0;
        for (ItemNota itemNota : listItemNota) {
            total += itemNota.getHargaJual() * itemNota.getJumlah();
        }
        textTotal.setText("Rp " + numberFormat.format(total) + ",00");
    }
}
